#ifndef MARCOS_H_20111011
#define MARCOS_H_20111011

#include "cocos2d.h"
#include <vector>
//#include "iconv.h"

#define  LAYER_SHOW_FUNC(layer) \
static void Show() \
{\
	cocos2d::CCScene *pNewScene = cocos2d::CCScene::create(); \
	layer *pLayer = layer::create();\
	pNewScene->addChild(pLayer); \
	cocos2d::CCScene *pCurScene = cocos2d::CCDirector::sharedDirector()->getRunningScene();\
	if(NULL == pCurScene)\
	{\
		cocos2d::CCDirector::sharedDirector()->runWithScene(pNewScene);}\
	else\
	{\
		cocos2d::CCDirector::sharedDirector()->replaceScene(pNewScene);\
	}\
};

#define CSTR(stdstr) (stdstr).c_str()

#define PANEL_SHOW_FUN_H(panel) \
private: \
static panel *s_pInstance; \
public: \
static void OpenWindow(int zOrder); \
static void CloseWindow(bool bCleanup); \
static panel *Instance() {return s_pInstance;} \

#define PANEL_SHOW_FUN_CPP(panel) \
panel *panel::s_pInstance = NULL; \
void panel::OpenWindow(int zOrder) \
{ \
	if(UIWindow::CurWindow() == NULL) return; \
	if(s_pInstance != NULL) \
	{ \
		s_pInstance->setVisible(true); \
		return; \
	} \
	s_pInstance = panel::create(); \
	UIWindow::CurWindow()->AddPanel(s_pInstance, zOrder); \
} \
void panel::CloseWindow(bool bCleanup) \
{ \
	if(UIWindow::CurWindow() == NULL || s_pInstance == NULL) \
		return; \
	if(bCleanup) \
	{ \
		UIWindow::CurWindow()->RemovePanel(s_pInstance); \
		s_pInstance = NULL; \
	} \
	else \
	{ \
		s_pInstance->setVisible(false); \
	} \
} \

#endif